'use strict';

angular.module('com.dcos.app').controller('TemplateSelectController',function($window,$state,$scope,$uibModalInstance,TemplateService) {
  var vm = this;

  vm.t_id="";

  vm.curProjectId=$window.sessionStorage.getItem("curProjectId");
  
  vm.templateData=[];

  vm.getList = function () { 
    TemplateService.list(vm.curProjectId).then(function (response) {
      if(response.data.templateList!=null){
        vm.templateData=response.data.templateList;
        vm.t_id=vm.templateData[0].t_id;
      }
    });
  }
  vm.getList();

  vm.ok = function () {
    $state.go('app.workflow.copyetemplate', {'t_id':vm.t_id});
    $uibModalInstance.dismiss('cancel');
  }

  vm.cancel = function () {
    $uibModalInstance.dismiss('cancel');
  };
});
